VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmToolApproval 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Approval Inbox"
   ClientHeight    =   7485
   ClientLeft      =   0
   ClientTop       =   -45
   ClientWidth     =   13125
   Icon            =   "frmToolApproval.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7485
   ScaleWidth      =   13125
   ShowInTaskbar   =   0   'False
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   6360
      Top             =   360
   End
   Begin MSComctlLib.ImageList ilMain 
      Left            =   2415
      Top             =   735
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   16711935
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   7
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":0442
            Key             =   "fldrClosed"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":09DC
            Key             =   "fldrOpen"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":0F76
            Key             =   "drive"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":1510
            Key             =   "explorer"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":1AAA
            Key             =   "genericLarge"
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":2144
            Key             =   "genericMedium"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":245E
            Key             =   "genericSmall"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TreeView tvTreeView 
      Height          =   6135
      Left            =   45
      TabIndex        =   0
      Top             =   810
      Width           =   3120
      _ExtentX        =   5503
      _ExtentY        =   10821
      _Version        =   393217
      Indentation     =   529
      LabelEdit       =   1
      LineStyle       =   1
      Style           =   7
      ImageList       =   "ilMain"
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSComctlLib.ImageList ilSmall 
      Left            =   3255
      Top             =   720
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   2
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":25B8
            Key             =   "genericSmall"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmToolApproval.frx":2712
            Key             =   "fldrClosed"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ListView lvListView 
      Height          =   6135
      Left            =   3165
      TabIndex        =   1
      Top             =   810
      Width           =   9105
      _ExtentX        =   16060
      _ExtentY        =   10821
      View            =   3
      LabelEdit       =   1
      Sorted          =   -1  'True
      MultiSelect     =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      HotTracking     =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   0
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Approval Inbox"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   240
      TabIndex        =   2
      Top             =   240
      Width           =   3615
   End
End
Attribute VB_Name = "frmToolApproval"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


Private connList As ADODB.Connection

'Object variables
Private connTrans As ADODB.Connection
Private cmdTrans As ADODB.Command
Private rsTrans As ADODB.Recordset


Private rsBalance As New Recordset

Enum eApprovalMode
    Normal
    Approved
End Enum

Public Mode As eApprovalMode


Enum sApprovalAction
    Q_Approve
    Q_Cancel
    Q_Override
End Enum

Enum eApprovalList
    SalesOrder
    ProductionOrder
    PurchaseRequisition
End Enum

Enum eApprovalType
    CreditApproval
    PriceApproval
    StockAvailability
End Enum



Public QApprovalAction As sApprovalAction
Public QApprovalRef As String
'Other declaration
Public sBit As String

Public mApprovalList As eApprovalList
Public mApprovalType As eApprovalType
'Public mApprovalAction As eApprovalAction
Public mInboxRef As String
Public mInboxRefCode As String
'Public mlCApproved As Boolean
'Public mlPApproved As Boolean

Dim sItem As String
Dim sModule As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean


Private Sub Form_Activate()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    
End Sub
Private Sub SetTrans()
Set cmdTrans = New ADODB.Command
    Set rsTrans = New ADODB.Recordset
    
    rsTrans.CursorLocation = adUseClient
    OpenNewConnection connTrans
    
    With cmdTrans
        .ActiveConnection = connTrans
        .CommandTimeout = 1000
        If SecUserRole <> "ADMIN" And SecUserRole <> "FINANCE" And SecUserRole <> "CEO" Then
            .CommandText = "sp_Transaction_Monitoring"
        Else
            .CommandText = "sp_Transaction_MonitoringWOCompany"
        End If
        .CommandType = adCmdStoredProc
        If SecUserRole <> "ADMIN" And SecUserRole <> "FINANCE" And SecUserRole <> "CEO" Then
            .Parameters("@cCompID") = COID
        End If
    End With
End Sub

Private Sub Form_Load()


    If Mode = Normal Then
        
       Set FrmName = Me
       
       FormSetup
    
       AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'TL06'")
    
        SetTrans
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , True, , , , , , , True
        BitVisible ITGLedgerMain.tbrMain, True, True
        ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
        
        Mode = Normal
        
        Me.Top = 0
        Me.Left = 2670
        'Me.WindowState = 2
    End If
    LoadTree
    mApprovalAction = A_Cancel
End Sub

 

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    CloseMenuTab ITGLedgerMain
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    Me.Tag = "Close"
    Set frmToolApproval = Nothing

    lCloseWindow = True
    
    Mode = Normal
    
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

Public Sub TBBitReload()
    'Not available in this form
End Sub

Sub LoadTree()
Dim nodRoot As Node
Dim newNode1 As Node
    
    
    Set nodRoot = tvTreeView.Nodes.Add(, , "Node1", "For Approval")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = True
    End With
        Set newNode1 = tvTreeView.Nodes.Add(nodRoot, 4, "Node11", "Sales Order", "fldrClosed", "fldrOpen")
'        AddTVNode newNode1, "Node1101", "Credit Approval", "fldrClosed", "fldrOpen"
'        AddTVNode newNode1, "Node1102", "Price Approval", "fldrClosed", "fldrOpen"
'        AddTVNode newNode1, "Node1103", "Stock Approval", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node12", "AR Adjustment", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node19", "Supply Requisition", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node13", "Purchase Request", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node14", "Purchase Order", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node15", "Canvassing", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node16", "Payable Setup", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node17", "Check Voucher", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node18", "Request for Payment", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node30", "Production Order", "fldrClosed", "fldrOpen"

    Set nodRoot = tvTreeView.Nodes.Add(, , "Node2", "Approved")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = False
    End With
        AddTVNode nodRoot, "Node21", "Sales Order", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node22", "AR Adjustment", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node29", "Supply Requisition", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node23", "Purchase Request", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node24", "Purchase Order", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node25", "Canvassing", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node26", "Payable Setup", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node27", "Check Voucher", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node28", "Request for Payment", "fldrClosed", "fldrOpen"
        AddTVNode nodRoot, "Node31", "Production Order", "fldrClosed", "fldrOpen"
        
    Set nodRoot = tvTreeView.Nodes.Add(, , "Node32", "Ready for Delivery")
    With nodRoot
        .Image = "fldrClosed"
        .Expanded = False
    End With
    

'    Set nodRoot = tvTreeView.Nodes.Add(, , "Node3", "Pending")
'    With nodRoot
'        .Image = "fldrClosed"
'        .Expanded = False
'    End With
'        AddTVNode nodRoot, "Node31", "Sales Order", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node32", "AR Adjustment", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node39", "Supply Requisition", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node33", "Purchase Request", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node34", "Purchase Order", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node35", "Canvassing", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node36", "Payable Setup", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node37", "Check Voucher", "fldrClosed", "fldrOpen"
'        AddTVNode nodRoot, "Node38", "Request for Payment", "fldrClosed", "fldrOpen"

Set nodRoot = tvTreeView.Nodes(1)

End Sub

Private Sub AddTVNode(ByRef ParentNode As Node, ByVal nodeKey As String, _
    ByVal nodeText As String, ByVal imgclose As String, ByVal imgopen As String)
    Dim newNode As Node
    Set newNode = tvTreeView.Nodes.Add(ParentNode, tvwChild, nodeKey, _
        nodeText, imgclose, imgopen)
End Sub

Private Sub lvListView_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvListView.Sorted = True
    If lvListView.SortOrder = lvwAscending Then
        lvListView.SortOrder = lvwDescending
    Else: lvListView.SortOrder = lvwAscending
    End If
End Sub

Private Sub ListReport(Optional Item As String)
On Error Resume Next
If Mode <> Approved Then
  Item = Me.tvTreeView.SelectedItem
  mItemParent = Me.tvTreeView.SelectedItem.Parent
'Else
End If
    With lvListView
        Select Case Item 'Me.tvTreeView.SelectedItem
            Case "Sales Order"
                    Set itmX = .ColumnHeaders.Add(, , "Order No.")
                    Set itmX = .ColumnHeaders.Add(, , "Date")
                    Set itmX = .ColumnHeaders.Add(, , "Client ID")
                    Set itmX = .ColumnHeaders.Add(, , "Client Name")
                    Set itmX = .ColumnHeaders.Add(, , "Cr. Limit")
                    Set itmX = .ColumnHeaders.Add(, , "Price")
                    
'                    .ColumnHeaders(1).Width = "96"
'                    .ColumnHeaders(2).Width = "96"
'                    .ColumnHeaders(3).Width = "96"
'                    .ColumnHeaders(4).Width = "96"
'                    .ColumnHeaders(5).Width = "96"
'                    .ColumnHeaders(6).Width = "96"

                    Do Until rsTrans.EOF
                        Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cSONO) & "")
                        itmX.SubItems(1) = Format(rsTrans!dDate, "MM/dd/yyyy") & ""
                        itmX.SubItems(2) = Trim(rsTrans!cCode) & ""
                        itmX.SubItems(3) = Trim(rsTrans!cName) & ""
                        itmX.SubItems(4) = IIf((rsTrans!lCApproved = True), "Approved", "For Approval") & ""
                        itmX.SubItems(5) = IIf((rsTrans!lPApproved = True), "Approved", "For Approval") & ""
                        rsTrans.MoveNext
                    Loop
                    

            Case "Purchase Request"
                    Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                    Set itmX = .ColumnHeaders.Add(, , "Date")
                    Set itmX = .ColumnHeaders.Add(, , "Type")
                    Set itmX = .ColumnHeaders.Add(, , "Ref. Number")
                    Set itmX = .ColumnHeaders.Add(, , "Date Needed")
                    Set itmX = .ColumnHeaders.Add(, , "Requested By")
        
                    .Checkboxes = True
'                    .ColumnHeaders(1).Width = "1200"
'                    .ColumnHeaders(2).Width = "1200"
'                    .ColumnHeaders(3).Width = "1200"
'                    .ColumnHeaders(4).Width = "1200"
'                    .ColumnHeaders(5).Width = "1200"
'                    .ColumnHeaders(6).Width = "1200"
        
                    Do Until rsTrans.EOF
                        Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                        itmX.SubItems(1) = Format(rsTrans!dDate, "dd/mm/yyyy") & ""
                        itmX.SubItems(2) = Trim(rsTrans!cType) & ""
                        itmX.SubItems(3) = Trim(rsTrans!cRefNo) & ""
                        itmX.SubItems(4) = Format(rsTrans!dNeeded, "dd/mm/yyyy") & ""
                        itmX.SubItems(5) = Trim(rsTrans!cRequestedBy) & ""
                        rsTrans.MoveNext
                    Loop
     
            Case "Canvassing"
                    Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                    Set itmX = .ColumnHeaders.Add(, , "Date")
                    Set itmX = .ColumnHeaders.Add(, , "Product ID")
                    Set itmX = .ColumnHeaders.Add(, , "Description")
                    Set itmX = .ColumnHeaders.Add(, , "Qty Needed")
                    
                    .Checkboxes = False
'                    .ColumnHeaders(1).Width = "1200"
'                    .ColumnHeaders(2).Width = "1200"
'                    .ColumnHeaders(3).Width = "1200"
'                    .ColumnHeaders(4).Width = "2750"
'                    .ColumnHeaders(5).Width = "1200"
    
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "dd/mm/yyyy") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cItemNo) & ""
                    itmX.SubItems(3) = Trim(rsTrans!cDesc) & ""
                    itmX.SubItems(4) = Format(IIf(IsNull(rsTrans!nQty), 0, rsTrans!nQty), "#,###.00")
                    rsTrans.MoveNext
                Loop
                
            Case "Supply Requisition"
                Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                Set itmX = .ColumnHeaders.Add(, , "Date")
                Set itmX = .ColumnHeaders.Add(, , "Type")
'                Set itmX = .ColumnHeaders.Add(, , "Item Type")
'                Set itmX = .ColumnHeaders.Add(, , "Product ID")
'                Set itmX = .ColumnHeaders.Add(, , "Description")
'                Set itmX = .ColumnHeaders.Add(, , "Current Inventory")
'                Set itmX = .ColumnHeaders.Add(, , "Last Req")
'                Set itmX = .ColumnHeaders.Add(, , "Qty Needed")
                
                .Checkboxes = True
'                .ColumnHeaders(1).Width = "1200"
'                .ColumnHeaders(2).Width = "1200"
'                .ColumnHeaders(3).Width = "1200"
'                .ColumnHeaders(4).Width = "2750"
'                .ColumnHeaders(5).Width = "1200"
'                .ColumnHeaders(6).Width = "1200"
'                .ColumnHeaders(7).Width = "1200"
'                .ColumnHeaders(7).Alignment = lvwColumnRight
'                .ColumnHeaders(8).Width = "1200"
'                .ColumnHeaders(9).Width = "1200"
'                .ColumnHeaders(9).Alignment = lvwColumnRight
                
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "MM/DD/YYYY") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cType) & ""
'                    itmX.SubItems(3) = Trim(rsTrans!cItemType) & ""
'                    itmX.SubItems(4) = Trim(rsTrans!cItemNo) & ""
'                    itmX.SubItems(5) = GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(rsTrans!cItemNo) & "'")
'                    If Me.tvTreeView.SelectedItem.Parent = "Approved" Then
'                        itmX.SubItems(6) = Format(GetValueFrTable("nBalance", "V_SuppliesBalanceInquiry_Module", "cSupplyNo = '" & Trim(rsTrans!cItemNo) & "'"), "#,##0.00")
'                    Else: itmX.SubItems(6) = Format(Trim(rsTrans!nQtyActual) & "", "#,##0.00")
'                    End If
'                    itmX.SubItems(7) = Trim(rsTrans!dApproved) & ""
'                    itmX.SubItems(8) = Format(Trim(rsTrans!nQty) & "", "#,##0.00")
    
                    rsTrans.MoveNext
                Loop
            
            Case "AR Adjustment"
                Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                Set itmX = .ColumnHeaders.Add(, , "Date")
                Set itmX = .ColumnHeaders.Add(, , "Type")
                Set itmX = .ColumnHeaders.Add(, , "Customer Code")
                Set itmX = .ColumnHeaders.Add(, , "Gross")
                Set itmX = .ColumnHeaders.Add(, , "Sales Return")
                
                .Checkboxes = True
'                .ColumnHeaders(1).Width = "1200"
'                .ColumnHeaders(2).Width = "1200"
'                .ColumnHeaders(3).Width = "1200"
'                .ColumnHeaders(4).Width = "1200"
'                .ColumnHeaders(5).Width = "1200"
                .ColumnHeaders(5).Alignment = lvwColumnRight
'                .ColumnHeaders(6).Width = "1200"
                                        
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "MM/DD/YYYY") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cType) & ""
                    itmX.SubItems(3) = Trim(rsTrans!cCode) & ""
                    itmX.SubItems(4) = Format(Trim(rsTrans!nGross) & "", "#,##0.00")
                    itmX.SubItems(5) = Trim(rsTrans!cSalesReturn) & ""
                    rsTrans.MoveNext
                Loop
                        
            Case "Purchase Order"
                Set itmX = .ColumnHeaders.Add(, , "PO No.")
                Set itmX = .ColumnHeaders.Add(, , "Date")
                Set itmX = .ColumnHeaders.Add(, , "PO Type")
                Set itmX = .ColumnHeaders.Add(, , "Item Type")
                Set itmX = .ColumnHeaders.Add(, , "Supplier Code")
                Set itmX = .ColumnHeaders.Add(, , "Gross")
                
                .Checkboxes = True
'                .ColumnHeaders(1).Width = "1200"
'                .ColumnHeaders(2).Width = "1200"
'                .ColumnHeaders(3).Width = "1200"
'                .ColumnHeaders(4).Width = "1200"
'                .ColumnHeaders(5).Width = "1200"
'                .ColumnHeaders(6).Width = "1200"
                .ColumnHeaders(6).Alignment = lvwColumnRight
                                        
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cPONo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "MM/DD/YYYY") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cPOType) & ""
                    itmX.SubItems(3) = Trim(rsTrans!cItemType) & ""
                    itmX.SubItems(4) = Trim(rsTrans!cCode) & ""
                    itmX.SubItems(5) = Format(Trim(rsTrans!nGross) & "", "#,##0.00")
                    rsTrans.MoveNext
                Loop
            Case "Payable Setup"
                Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                Set itmX = .ColumnHeaders.Add(, , "Date")
                Set itmX = .ColumnHeaders.Add(, , "Supplier Code")
                Set itmX = .ColumnHeaders.Add(, , "Ref. No.")
                Set itmX = .ColumnHeaders.Add(, , "Terms")
                Set itmX = .ColumnHeaders.Add(, , "Amount")
                
                .Checkboxes = True
'                .ColumnHeaders(1).Width = "1200"
'                .ColumnHeaders(2).Width = "1200"
'                .ColumnHeaders(3).Width = "1200"
'                .ColumnHeaders(4).Width = "1200"
'                .ColumnHeaders(5).Width = "1200"
'                .ColumnHeaders(6).Width = "1200"
                .ColumnHeaders(6).Alignment = lvwColumnRight
                                        
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "MM/DD/YYYY") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cCode) & ""
                    itmX.SubItems(3) = Trim(rsTrans!cRefNo) & ""
                    itmX.SubItems(4) = Trim(rsTrans!cTerms) & ""
                    itmX.SubItems(5) = Format(Trim(rsTrans!nAmount) & "", "#,##0.00")
                    rsTrans.MoveNext
                Loop
                
            Case "Request for Payment"
                Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                Set itmX = .ColumnHeaders.Add(, , "Date")
                Set itmX = .ColumnHeaders.Add(, , "Supplier Code")
                Set itmX = .ColumnHeaders.Add(, , "Date Needed")
                Set itmX = .ColumnHeaders.Add(, , "Payment For")
                Set itmX = .ColumnHeaders.Add(, , "Type")
                
                .Checkboxes = True
'                .ColumnHeaders(1).Width = "1200"
'                .ColumnHeaders(2).Width = "1200"
'                .ColumnHeaders(3).Width = "1200"
'                .ColumnHeaders(4).Width = "1200"
'                .ColumnHeaders(5).Width = "2750"
'                .ColumnHeaders(6).Width = "1200"
                                        
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "MM/DD/YYYY") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cCode) & ""
                    itmX.SubItems(3) = Format(rsTrans!dDateNeeded, "MM/DD/YYYY") & ""
                    itmX.SubItems(4) = Trim(rsTrans!cPayfor) & ""
                    itmX.SubItems(5) = Trim(rsTrans!cType) & ""
                    rsTrans.MoveNext
                Loop
                
            Case "Check Voucher"
                Set itmX = .ColumnHeaders.Add(, , "Trans. No")
                Set itmX = .ColumnHeaders.Add(, , "Date")
                Set itmX = .ColumnHeaders.Add(, , "Supplier Code")
                Set itmX = .ColumnHeaders.Add(, , "Type")
                Set itmX = .ColumnHeaders.Add(, , "Specs")
                Set itmX = .ColumnHeaders.Add(, , "Amount")
                
                .Checkboxes = True
'                .ColumnHeaders(1).Width = "1200"
'                .ColumnHeaders(2).Width = "1200"
'                .ColumnHeaders(3).Width = "1200"
'                .ColumnHeaders(4).Width = "1200"
'                .ColumnHeaders(5).Width = "2750"
'                .ColumnHeaders(6).Width = "1200"
                                        
                Do Until rsTrans.EOF
                    Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                    itmX.SubItems(1) = Format(rsTrans!dDate, "MM/DD/YYYY") & ""
                    itmX.SubItems(2) = Trim(rsTrans!cCode) & ""
                    itmX.SubItems(3) = Trim(rsTrans!cType) & ""
                    itmX.SubItems(4) = Trim(rsTrans!cSpec) & ""
                    itmX.SubItems(5) = Format(rsTrans!nTDebit, "#,##0.00") & ""
                    rsTrans.MoveNext
                Loop
                
        Case "Production Order"
                    Set itmX = .ColumnHeaders.Add(, , "Trans No.")
                    Set itmX = .ColumnHeaders.Add(, , "Date")
                    Set itmX = .ColumnHeaders.Add(, , "Reference DR No.")
                    Set itmX = .ColumnHeaders.Add(, , "Reference WRR No.")
                    Set itmX = .ColumnHeaders.Add(, , "Date Needed")
                    Set itmX = .ColumnHeaders.Add(, , "Type")
                    Set itmX = .ColumnHeaders.Add(, , "Remarks")

'                    .ColumnHeaders(1).Width = "1200"
'                    .ColumnHeaders(2).Width = "1250"
'                    .ColumnHeaders(3).Width = "1200"
'                    .ColumnHeaders(4).Width = "1250"
'                    .ColumnHeaders(5).Width = "1500"
'                    .ColumnHeaders(6).Width = "2500"

                    .Checkboxes = True
                    Do Until rsTrans.EOF
                        Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cTranNo) & "")
                        itmX.SubItems(1) = Format(rsTrans!dDate, "MM/dd/yyyy") & ""
                        itmX.SubItems(2) = Trim(rsTrans!cRefDRNo) & ""
                        itmX.SubItems(3) = Trim(rsTrans!cRefWRRNo) & ""
                        itmX.SubItems(4) = Format(rsTrans!dNeeded, "MM/dd/yyyy") & ""
                        itmX.SubItems(5) = Trim(rsTrans!cType) & ""
                        itmX.SubItems(6) = Trim(rsTrans!cRemarks) & ""
                        rsTrans.MoveNext
                    Loop
                    
                    
        Case "Ready for Delivery"
                
                    Set itmX = .ColumnHeaders.Add(, , "Receipt No.")
                    Set itmX = .ColumnHeaders.Add(, , "Date")
                    Set itmX = .ColumnHeaders.Add(, , "Client ID")
                    Set itmX = .ColumnHeaders.Add(, , "Remarks")
                                               
'                    .ColumnHeaders(1).Width = "1200"
'                    .ColumnHeaders(2).Width = "1250"
'                    .ColumnHeaders(3).Width = "1300"
'                    .ColumnHeaders(4).Width = "4000"
                    
                    .Checkboxes = False
                    Do Until rsTrans.EOF
                        Set itmX = lvListView.ListItems.Add(, , Trim(rsTrans!cDRNo) & "")
                        itmX.SubItems(1) = Format(rsTrans!dDate, "MM/dd/yyyy") & ""
                        itmX.SubItems(2) = Trim(rsTrans!cDelCode) & ""
                        itmX.SubItems(3) = Trim(rsTrans!cRemarks) & ""
                        rsTrans.MoveNext
                    Loop
                      
                Exit Sub
        End Select
        
        
'        If Me.tvTreeView.SelectedItem.Parent = "Approved" Or Me.tvTreeView.SelectedItem.Parent = "Pending" Then .Checkboxes = False
        If mItemParent = "Approved" Or mItemParent = "Pending" Then .Checkboxes = False
        
    End With
End Sub

Private Sub lvListView_DblClick()
'Dim sModule, sFrmName As String
If lvListView.ListItems.Count = 0 Then Exit Sub

    Select Case Me.tvTreeView.SelectedItem
        Case "Purchase Request"
'            Set FrmName = frmAPPurchaseRequest
'            sFrmName = "frmAPPurchaseRequest"
'            sModule = "Purchase Requisition"
        Case "Canvassing"
'            Set FrmName = frmEnhanceCanvass
'            sFrmName = "frmEnhanceCanvass"
'            sModule = "Canvassing"
        Case "Supply Requisition"
'            Set FrmName = frmEnhanceRequisitionSlip
'            sFrmName = "frmEnhanceRequisitionSlip"
'            sModule = "Supply Requisition"
        Case "Sales Order"
            Set FrmName = frmBasicARSalesOrder
            sFrmName = "frmBasicARSalesOrder"
            sModule = "Sales Order"
                           
        Case "Production Order", "Ready for Delivery"
            'Set FrmName = frmMFGProductionOrder
            'sModule = "Production Order"
            Exit Sub
            
        Case "AR Adjustment"
            Set FrmName = frmBasicARAdjustments
            sFrmName = "frmBasicARAdjustments"
            sModule = "AR Adjustment"
        Case "Purchase Order"
            Set FrmName = frmBasicAPPurchaseOrder
            sFrmName = "frmBasicAPPurchaseOrder"
            sModule = "Purchase Order"
        Case "Payable Setup"
            Set FrmName = frmBasicAPSetup
            sFrmName = "frmBasicAPSetup"
            sModule = "Payable Setup"
        Case "Request for Payment"
'            Set FrmName = frmAPRFP
'            sFrmName = "frmAPRFP"
'            sModule = "Request for Payment"
        Case "Check Voucher"
            Set FrmName = frmBasicAPVoucherMain
            sFrmName = "frmBaiscAPVoucherMain"
            sModule = "Check Voucher"
    End Select
    
    With FrmName
        If .Mode = 1 Then
            MsgBox "Sytem detected that '" & Trim(sModule) & "' is in Add/Edit mode." & _
                    vbCr & "Please save/undo the current transaction.", vbCritical + vbOKOnly, "Comunion"
            FrmName.SetFocus
            Exit Sub
        Else
'            .Mode = 2
'            .Show
'            .ShowForm (lvListView.SelectedItem)
            ShowForm
        End If
    End With
End Sub

Private Sub Timer1_Timer()
If mApprovalAction = A_Approve Or mApprovalAction = A_Override Then
    tvTreeView_Click
    Call ListReport(sItem)
    mApprovalAction = A_Cancel
    Exit Sub
End If
End Sub

Private Sub tvTreeView_Click()
    SetTrans
    lvListView.ColumnHeaders.Clear
    lvListView.ListItems.Clear

    If rsTrans.State = adStateOpen Then rsTrans.Close

    If Mode = Approved Then
   
        Select Case sItem
            Case "Canvassing", "Purchase Request", "Supply Requisition", "Sales Order", _
                "AR Adjustment", "Purchase Order", "Payable Setup", "Request for Payment", _
                "Check Voucher", "Production Order"
                cmdTrans.Parameters("@cEvent") = mItemParent
                cmdTrans.Parameters("@cModule") = sItem
            Case "Ready for Delivery"
                cmdTrans.Parameters("@cEvent") = "Approved"
                cmdTrans.Parameters("@cModule") = "Ready for Delivery"
            Case Else
                Exit Sub
        End Select
    Else
        Select Case Me.tvTreeView.SelectedItem
            Case "Canvassing", "Purchase Request", "Supply Requisition", "Sales Order", _
                "AR Adjustment", "Purchase Order", "Payable Setup", "Request for Payment", _
                "Check Voucher", "Production Order"
                cmdTrans.Parameters("@cEvent") = Me.tvTreeView.SelectedItem.Parent
                cmdTrans.Parameters("@cModule") = Me.tvTreeView.SelectedItem
            Case "Ready for Delivery"
                cmdTrans.Parameters("@cEvent") = "Approved"
                cmdTrans.Parameters("@cModule") = "Ready for Delivery"
            Case Else
                Exit Sub
        End Select
    End If


    
    
    Set rsTrans = Nothing
    Set rsTrans = cmdTrans.Execute()

    Call ListReport
    
End Sub

'Post current record
Public Sub TBPostRecord()
On Error GoTo TheSource
    
    If SecUserRole = "ADMIN" Or SecUserRole = "FINANCE" Or SecUserRole = "CEO" Then
        TBPostRecordWOComapny
        Exit Sub
    End If
    
    If rsTrans.RecordCount = 0 Then Exit Sub
    With Me.lvListView
        If Me.tvTreeView.SelectedItem.Parent = "For Approval" Then
            Select Case Me.tvTreeView.SelectedItem
                Case "Purchase Request"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE REQUISITION set lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cPRNo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "Purchase Request", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                    
                Case "Canvassing"
'                     QApprovalRef = .SelectedItem.Text
'                     frmApprovalCanvass.Show vbModal
'
'                    If QApprovalAction = Q_Approve Then
'                        MsgBox "Canvass was approved successfully.", vbExclamation, "ComUnion"
'                        .ListItems.Remove (.SelectedItem.Index)
'                    ElseIf QApprovalAction = Q_Override Then
'                        MsgBox "Override successful. Canvass was successfully approved.", vbExclamation, "ComUnion"
'                    End If
                    
                Case "Supply Requisition"
'                    For i = .ListItems.Count To 1 Step -1
'                            If .ListItems(i).Checked Then
'                                cn.Execute ("UPDATE REQUISITIONSLIP_T " & _
'                                                        " SET lApproved = 1,cApprovedBy = '" & sUserName & "', " & _
'                                                        " dApproved = '" & Now() & "' ," & _
'                                                        " cApproved = '" & Trim(SecUserID) & "', " & _
'                                                        " nQtyActual = '" & Trim(.ListItems(i).SubItems(6)) & "'  " & _
'                                                        " WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "'  " & _
'                                                        " And cItemNo = '" & Trim(.ListItems(i).SubItems(4)) & "'  " & _
'                                                        " And cCompanyID = '" & COID & "'")
'                                UpdateLogFile "Supply Requisition", Trim(.ListItems(i).Text) + ": " + " Trim(.ListItems(i).SubItems(5)) ", "Approved"
'                                .ListItems.Remove (.ListItems(i).Index)
'                            End If
'                    Next i
'                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                    
                Case "AR Adjustment"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE AR set  dUpdated = GETDATE (),  lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "AR Adjustment", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                                        
                Case "Purchase Order"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE PO set  dUpdated = GETDATE () ,lApproved = 1, cApprovedBy = '" & sUserName & "' WHERE cPONo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "Purchase Order", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                    
                Case "Payable Setup"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE PAYABLES set  dUpdated = GETDATE (), lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "Payable Setup", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                    
                Case "Request for Payment"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE RFP set  dUpdated = GETDATE (), lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "Request for Payment", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                                    
                Case "Check Voucher"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE VOUCHER set  dUpdated = GETDATE (), lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "Check Voucher", Trim(.ListItems(i).Text), "Approved"
                                
                                'Update GL Activity
                                UpdateGLA "Update", "VOU", Trim(.ListItems(i).Text)
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                Case "Production Order" 'add by denz:2/18/2011
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE PRODUCTION set  dUpdated = GETDATE (), lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "' AND cCompanyID = '" & COID & "'")
                                UpdateLogFile "Production Order", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                Case Else
                    Exit Sub
            End Select
        End If
    End With
    
TheSource:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub


Public Sub TBPostRecordWOComapny()
On Error GoTo TheSource
    
    If rsTrans.RecordCount = 0 Then Exit Sub
    With Me.lvListView
        If Me.tvTreeView.SelectedItem.Parent = "For Approval" Then
            Select Case Me.tvTreeView.SelectedItem
                Case "Purchase Request"
                Case "Canvassing"
                Case "Supply Requisition"
                Case "AR Adjustment"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE AR set lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "'")
                                UpdateLogFile "AR Adjustment", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                Case "Purchase Order"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE PO set lApproved = 1, cApprovedBy = '" & sUserName & "' WHERE cPONo = '" & Trim(.ListItems(i).Text) & "'")
                                UpdateLogFile "Purchase Order", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                Case "Payable Setup"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE PAYABLES set lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "'")
                                UpdateLogFile "Payable Setup", Trim(.ListItems(i).Text), "Approved"
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                Case "Request for Payment"
                Case "Check Voucher"
                    For i = .ListItems.Count To 1 Step -1
                            If .ListItems(i).Checked Then
                                cn.Execute ("UPDATE VOUCHER set lApproved = 1,cApprovedBy = '" & sUserName & "' WHERE cTranNo = '" & Trim(.ListItems(i).Text) & "'")
                                UpdateLogFile "Check Voucher", Trim(.ListItems(i).Text), "Approved"
                                
                                'Update GL Activity
                                UpdateGLA "Update", "VOU", Trim(.ListItems(i).Text)
                                .ListItems.Remove (.ListItems(i).Index)
                            End If
                    Next i
                    MsgBox "Record(s) successfully approved.", vbInformation + vbOKOnly, "Comunion"
                Case Else
                    Exit Sub
            End Select
        End If
    End With
    
TheSource:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub


'Right click menu popup
Private Sub lvListView_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If sItem = "" Then
    sItem = Me.tvTreeView.SelectedItem
'End If
Select Case sItem
    Case "Sales Order"
        If lvListView.ListItems.Count = 0 Then Exit Sub

        mInboxRef = Trim(lvListView.SelectedItem.Text)
        mInboxRefCode = Trim(lvListView.SelectedItem.SubItems(2))
        mSONo = Trim(lvListView.SelectedItem.Text)
        mCode = Trim(lvListView.SelectedItem.SubItems(2))

        If mApprovalList = SalesOrder Then
            mlCApproved = IIf((lvListView.SelectedItem.SubItems(4) = "Approved"), True, False)
            mlPApproved = IIf((lvListView.SelectedItem.SubItems(5) = "Approved"), True, False)
        End If
        
        If Button = 2 Then
            PopupMenu ITGLedgerMain.mnuApproval
        End If
     
'    Case "Production Order" 'Disable by denz:2/18/2011 Posting will be use
'        If lvListView.ListItems.Count = 0 Then Exit Sub
'
'        If Button = 2 Then
'            PopupMenu ITGLedgerMain.mnuLabor
'        End If
        
    
    End Select
End Sub

'Transaction approval
Public Sub TransApproved()
'On Error Resume Next
    
    Select Case mApprovalList
        Case SalesOrder
            Select Case mApprovalType
                Case CreditApproval
                    If Not GetValueFrTable("lGroupLimit", "CLIENT_CUSTOMER", "cCode = '" & mCode & "'") Then
                        frmApprovalDetails.Show vbModal
                    Else
                        frmApprovalDetailsPC.Show vbModal
                    End If
                    If mApprovalAction <> A_Cancel Then
                        cn.Execute ("UPDATE SO SET dUpdated = GETDATE () WHERE cSONo = '" & Trim(mSONo) & "' AND cCompanyID = '" & COID & "'")
                        cn.Execute "UPDATE SO SET lCApproved = 1, cCApprovedBy = '" & SecUserName & "' WHERE cSONo = '" & mSONo & "' AND cCompanyID = '" & COID & "'"
                        sItem = "Sales Order"
                        Mode = Approved
                        mItemParent = "For Approval"
                        UpdateLogFile "Credit Approval", mSONo, "Credit Approved"
                        Mode = Normal
                    End If
                    If mApprovalAction = A_Approve Then
                        MsgBox "Sales order was credit approved successfully.", vbExclamation, "ComUnion"
                    ElseIf mApprovalAction = A_Override Then
                        'Print overriding document
                        MsgBox "Override successful. Sales order was approved.", vbExclamation, "ComUnion"
                    End If
                Case PriceApproval
                    frmApprovalPriceDetails.Show vbModal
'                    mSONo = mInboxRef
                    If mApprovalAction = A_Approve Then
                        cn.Execute "UPDATE SO SET lPApproved = 1, cPApprovedBy = '" & SecUserName & "' WHERE cSONo = '" & mSONo & "' AND cCompanyID = '" & COID & "'"
                        sItem = "Sales Order"
                        Mode = Approved
                        mItemParent = "For Approval"
                        UpdateLogFile "Price Approval", mSONo, "Price Approved"
                        MsgBox "Sales order was price approved successfully.", vbExclamation, "ComUnion"
'                        Timer1.Enabled = True
                        Mode = Normal
                    End If
                Case StockAvailability
                    frmApprovalStockDetails.Show vbModal
'                    mSONo = mInboxRef
'                    mCode = mInboxRefCode
                    If mApprovalAction = A_Approve Then
                        UpdateLogFile "Stock Approval", mInboxRef, "Stock Approved"
                        MsgBox "Sales order was stock approved successfully.", vbExclamation, "ComUnion"
                    End If
            End Select
    End Select
    
End Sub

Public Sub TransApprovedWOCompany()
'On Error Resume Next
    If SecUserRole = "ADMIN" Or SecUserRole = "FINANCE" Or SecUserRole = "CEO" Then
        TransApprovedWOCompany
        Exit Sub
    End If
    Select Case mApprovalList
        Case SalesOrder
            Select Case mApprovalType
                Case CreditApproval
                    If Not GetValueFrTable("lGroupLimit", "CLIENT_CUSTOMER", "cCode = '" & mCode & "'") Then
                        frmApprovalDetails.Show vbModal
                    Else
                        frmApprovalDetailsPC.Show vbModal
                    End If
                    If mApprovalAction <> A_Cancel Then
                        cn.Execute "UPDATE SO SET lCApproved = 1, cCApprovedBy = '" & SecUserName & "' WHERE cSONo = '" & mSONo & "'"
                        sItem = "Sales Order"
                        Mode = Approved
                        mItemParent = "For Approval"
                        UpdateLogFile "Credit Approval", mSONo, "Credit Approved"
                        Mode = Normal
                    End If
                    If mApprovalAction = A_Approve Then
                        MsgBox "Sales order was credit approved successfully.", vbExclamation, "ComUnion"
                    ElseIf mApprovalAction = A_Override Then
                        'Print overriding document
                        MsgBox "Override successful. Sales order was approved.", vbExclamation, "ComUnion"
                    End If
                Case PriceApproval
                    frmApprovalPriceDetails.Show vbModal
'                    mSONo = mInboxRef
                    If mApprovalAction = A_Approve Then
                        cn.Execute "UPDATE SO SET lPApproved = 1, cPApprovedBy = '" & SecUserName & "' WHERE cSONo = '" & mSONo & "'"
                        sItem = "Sales Order"
                        Mode = Approved
                        mItemParent = "For Approval"
                        UpdateLogFile "Price Approval", mSONo, "Price Approved"
                        MsgBox "Sales order was price approved successfully.", vbExclamation, "ComUnion"
                        Mode = Normal
                    End If
                Case StockAvailability
                    frmApprovalStockDetails.Show vbModal
'                    mSONo = mInboxRef
'                    mCode = mInboxRefCode
                    If mApprovalAction = A_Approve Then
                        UpdateLogFile "Stock Approval", mInboxRef, "Stock Approved"
                        MsgBox "Sales order was stock approved successfully.", vbExclamation, "ComUnion"
                    End If
            End Select
    End Select
    
End Sub


Public Sub POApproval()
    If SecUserRole = "ADMIN" Or SecUserRole = "FINANCE" Or SecUserRole = "CEO" Then
        POApprovalWOCompany
        Exit Sub
    End If
        cn.Execute "UPDATE production_fg SET lApproved = 1 where cCompanyID = '" & COID & "' and cTranNo = '" & lvListView.ListItems(lvListView.SelectedItem.Index).Text & "' and cItemNo = '" & lvListView.SelectedItem.ListSubItems(4).Text & "'"
                
End Sub

Public Sub POApprovalWOCompany()
        cn.Execute "UPDATE production_fg SET lApproved = 1 where cTranNo = '" & lvListView.ListItems(lvListView.SelectedItem.Index).Text & "' and cItemNo = '" & lvListView.SelectedItem.ListSubItems(4).Text & "'"
End Sub
Private Sub ShowForm()
    
        sTabTxt = "Operation"
        sNodeCode = GetValueFrTable("module_code", "erp_sec_modules", "link = '" & sFrmName & "'", True)
        sNodeTxt = GetValueFrTable("module", "erp_sec_modules", "link = '" & sFrmName & "'", True)
        nNodeIndex = GetValueFrTable("module_id", "erp_sec_modules", "link = '" & sFrmName & "'", True)
        sLink = sFrmName
        lClicked = False
        ITGLedgerMain.mpNavigation_ElementClicked
        lApprovalShow = True
        
        If FrmName.Mode = 1 Then
            MsgBox "Unable to view transaction. You are in Add/New/Edit mode." & vbCr & _
                " Must Save or Undo", vbCritical, GetValueFrTable("module", "erp_sec_modules", "link = '" & sFrmName & "'", True) & " Approval"
            BitEnabled ITGLedgerMain, FrmName, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
            Exit Sub
        End If
        
        SetFormTranNo
        FrmName.Mode = 2
        If SecUserRole = "ADMIN" Or SecUserRole = "FINANCE" Or SecUserRole = "CEO" Or SecUserRole = "SUPERUSER" Then
            FrmName.ShowTran
        Else
            FrmName.TBFindPrimary
        End If
        lClicked = True
    
End Sub

Private Sub SetFormTranNo()
    If sFrmName = "frmBasicARSalesOrder" Then
        FrmName.txtSONo = lvListView.SelectedItem
    ElseIf sFrmName = "frmBasicAPPurchaseOrder" Then
        FrmName.txtPONo = lvListView.SelectedItem
    ElseIf sFrmName = "frmAPPurchaseRequest" Then
        FrmName.txtPRNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmAPVoucherMain" Then
        FrmName.txtVoucherNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmEnhanceRequisitionSlip" Then
        FrmName.txtTranNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmEnhanceSupplyIssuance" Then
        FrmName.txtTranNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmEnhanceCanvass" Then
        FrmName.txtTranNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmAPRFP" Then
        FrmName.txtTranNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmAPSetup" Then
        FrmName.txtTranNo = lvListView.SelectedItem
    ElseIf sFrmName = "frmBasicARAdjustments" Then
        FrmName.txtTranNo = lvListView.SelectedItem
    End If
End Sub
